<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@taglib prefix="sec"
	uri="http://www.springframework.org/security/tags"%>


<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>${applicationScope.KEY_SITE_NAME}</title>
<link href="resources/css/jquery-ui.css" rel="stylesheet"
	type="text/css" />
<link href="resources/css/ichecker/square/blue.css" rel="stylesheet"
	type="text/css" />
<link href="resources/css/intstyle.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="resources/scripts/jquery-1.9.1.js"></script>
<script type="text/javascript"
	src="resources/scripts/jquery-ui.custom.js"></script>
<script type="text/javascript" src="resources/scripts/jquery.blockUI.js"></script>
<script type="text/javascript" src="resources/scripts/jquery.icheck.js"></script>
<script type="text/javascript" src="resources/scripts/common.js"></script>
<script type="text/javascript"
	src="resources/scripts/jquery.validate.js"></script>

<script type="text/javascript">
<!--
	$(document)
			.ready(
					function() {

						renderButtons();
						changeSideMenuBackColor("sideMenuIntUsrAdd");
						renderCheckBox();
						
						$("#form1")
								.validate(
										{
											rules : {
												userId : {
													required : true,
													maxlength : 30,
													minlength : 6,
													remote : {
														url : 'user/checkuserid',
														type : 'POST',
														dateType : 'json',
														data : {
															userId : function() {
																return $('#userId').val();
															}
														}
													}
												},
												userM : {
													required : true,
													maxlength : 40,
													minlength : 2
												},
												password : {
													required : true,
													minlength : 5,
													maxlength : 30
												},
												re_passwrod : {
													required : true,
													minlength : 5,
													maxlength : 30,
													equalTo : "#password"
												},
												qq : {
													maxlength : 60
												},
												email : {
													email : true,
													maxlength : 60
												}

											},
											messages : {
												userId : {
													required : "<spring:message code='msg.input.field.required'/>",
													maxlength : jQuery
															.format("<spring:message code='msg.input.field.maxlength'/>"),
													minlength : jQuery
															.format("<spring:message code='msg.input.field.minlength'/>"),
													remote : "<spring:message code='msg.input.user.exists'/>"
												},
												userM : {
													required : "<spring:message code='msg.input.field.required'/>",
													maxlength : jQuery
															.format("<spring:message code='msg.input.field.maxlength'/>"),
													minlength : jQuery
															.format("<spring:message code='msg.input.field.minlength'/>")
												},
												password : {
													required : "<spring:message code='msg.input.field.required'/>",
													maxlength : jQuery
															.format("<spring:message code='msg.input.field.maxlength'/>"),
													minlength : jQuery
															.format("<spring:message code='msg.input.field.minlength'/>")
												},
												re_passwrod : {
													required : "<spring:message code='msg.input.field.required'/>",
													maxlength : jQuery
															.format("<spring:message code='msg.input.field.maxlength'/>"),
													minlength : jQuery
															.format("<spring:message code='msg.input.field.minlength'/>"),
													equalTo : "<spring:message code='msg.input.password.notEqual'/>"
												},
												qq : {
													maxlength :  jQuery.format("<spring:message code='msg.input.field.maxlength'/>")
												},
												email : {
													email : "<spring:message code='msg.input.email.format'/>",
													maxlength : jQuery.format("<spring:message code='msg.input.field.maxlength'/>")
												}
											},

											submitHandler : function (form) {
												saveAdminUser();
											}

										});

					});

	function saveAdminUser() {

		getBlockUI();
		$.post("admin/user/internal/save", $("#form1").serialize(), function(obj,
				html) {
			$.unblockUI();
			if (obj.accessDenied) {
				showInfoDialog("error",data.message);	
			} else {
				showInfoDialog("success","<spring:message code='msg.dialog.save.ok'/>");
				$('#reset').click();
			}
		});
	}
//-->
</script>

<!--[if lte IE 7]>
<style>
.content { margin-right: -1px; } /* 此 1px 负边距可以放置在此布局中的任何列中，且具有相同的校正效果。 */
ul.nav a { zoom: 1; }  /* 缩放属性将为 IE 提供其需要的 hasLayout 触发器，用于校正链接之间的额外空白 */
</style>
<![endif]-->
</head>

<body>

	<div class="container">
		<%@include file="../header.jsp"%>
		<%@include file="sidebar.jsp"%>
		<div id="contentBoxDiv" class="content">
			<div class="subnav">
				<spring:message code="Label.menu.headnav.user" />
				&gt;&gt;
				<spring:message code="Label.menu.sidenav.user.title.int" />
				&gt;&gt;
				<spring:message code="Label.menu.sidenav.user.int.add" />
			</div>
			<%@include file="../errorMessagePanel.jsp"%>
			<div class="box">
				<h2>
						<spring:message code="Label.user.internal.info" />
				</h2>

				<div class="box" style="border: none;">

					<form id="form1" name="form1" method="post" action="">

						<fieldset>
							<div class="formfield">

								<div class="formLabel">
									<label for="userId"><spring:message
											code="Label.adminuser.id" /></label>
								</div>
								<div class="forminput">
									<input type="text" id="userId" name="userId"
										class="text ui-widget-content ui-corner-all" />
								</div>

							</div>

							<div class="formfield">

								<div class="formLabel">
									<label for="userM"><spring:message
											code="Label.adminuser.name" /></label>
								</div>
								<div class="forminput">
									<input type="text" id="userM" name="userM"
										class="text ui-widget-content ui-corner-all" />
								</div>

							</div>

							<div class="formfield">

								<div class="formLabel">
									<label for="password"><spring:message
											code="Label.adminuser.password" /></label>
								</div>
								<div class="forminput">
									<input type="password" id="password" name="password"
										class="text ui-widget-content ui-corner-all" />
								</div>

							</div>

							<div class="formfield">

								<div class="formLabel">
									<label for="re_passwrod"><spring:message
											code="Label.adminuser.repassword" /></label>
								</div>
								<div class="forminput">
									<input type="password" id="re_passwrod" name="re_passwrod"
										class="text ui-widget-content ui-corner-all" />
								</div>

							</div>
							
							<div class="formfield">

								<div class="formLabel">
									<label for="qq"><spring:message
											code="Label.user.buyer.qq" /></label>
								</div>
								<div class="forminput">
									<input type="text" id="qq" name="qq"
										class="text ui-widget-content ui-corner-all" />
								</div>

							</div>
							
							<div class="formfield">

								<div class="formLabel">
									<label for="email"><spring:message
											code="Label.user.buyer.email" /></label>
								</div>
								<div class="forminput">
									<input type="text" id="email" name="email"
										class="text ui-widget-content ui-corner-all" />
								</div>

							</div>
							
							<div class="formfield">

								<div class="formLabel">
									<label for="role"><spring:message
											code="Label.user.role" /></label>
								</div>
								
								<div class="forminput">
									<div class="button-group-div" style="width:50%">
	
										<c:if test="${not empty roleList}">
											<c:forEach items="${roleList}" var="role">
												<div id="authListCol" style="width: 150px; margin-bottom: 12px;">
					
													<div>
														<input type="checkbox" name="selectedRoleList"
															id="check${role.roleId}" value="${role.roleId}" />
													</div>
					
													<div>
														<label for="check${role.roleId}" id="label${role.roleId}"><spring:message
																code="${role.roleName}" /></label>
													</div>
												</div>
											</c:forEach>
										</c:if>
						
									</div>
								</div>
								<div class="clearfloat"></div>

							</div>

							<div class="forminput">
								<button type="submit" id="submitbtn">
									<spring:message code='Label.common.save' />
								</button>
								<button type="reset" id="reset">
									<spring:message code='Label.common.reset' />
								</button>
							</div>

						</fieldset>
					</form>

				</div>
			</div>

			<!-- end .content -->
		</div>
		<div class="clearfloat" />
		<%@include file="../footer.jsp"%>
		<!-- end .container -->
	</div>
</body>
</html>